home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / GETPSP.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  693 b   |  22 lines

  1. /* GETPSP.C --- p. 612 */
  2. #include <stdio.h>
  3. #include <dos.h>
  4. main()
  5. {
  6.     unsigned int mypsp, last_seg;
  7.     long mem_allocated;
  8.             /* If DOS version is at least 3.0, call getpsp */
  9.     if(_osmajor == 3)
  10.     mypsp = getpsp();
  11.             /* else use global variable _psp to access PSP */
  12.     else
  13.         mypsp = _psp;
  14.                 /* Display some infomation from PSP */
  15.     printf("PSP starts at %X:0000\n", mypsp);
  16.             /* Address of last allocated memory is at offset 2 */
  17.     last_seg = *((unsigned far *)(MK_FP(mypsp, 2)));
  18.     printf("End of allocated memory at %X:000\n", last_seg);
  19.     mem_allocated = 16*(long)(last_seg - mypsp);
  20.     printf("%ld bytes  of memory allocated to this "
  21.                     "program\n", mem_allocated);
  22. }